package com.candy.homework;

/**
 * @author donglin
 * @Title:
 * @类名: Rectangle
 * @date 2020/7/23
 */
public class Rectangle {
    //长length、宽width
    int length;
    int width;
    //通过构造方法Rectangle(int width, int length)，分别给两个属性赋值


    public Rectangle(int length, int width) {
        this.length = length;
        this.width = width;
    }


    //getArea()求面积、getPer()求周长，showAll()分别在控制台输出长、宽、面积、周长。
    public int getArea(){
        return width*length;

    }
    public int getPer(){
        return (width+length)*2;
    }
    public void showAll(){
        System.out.println("长："+length+"，宽："+width+",面积："+this.getArea()+",周长："+this.getPer());

    }
}
